package v1

import (
	"context"
	"wxpay/internal/service"
	v1 "wxpay/pkg/api/v1"
	"wxpay/pkg/merrors"

	"github.com/golang/protobuf/ptypes/empty"
)

func (s *Server) ScheduleMessageToBePublishedCheck(ctx context.Context, e *empty.Empty) (*v1.OperationResult, error) {
	const op merrors.Op = "server.ScheduleMessageToBePublishedCheck"
	if err := service.NewMessageService(s.d).ScanThenInQueue(ctx); err != nil {
		return nil, merrors.E(op, merrors.Invalid, err)
	}
	return &v1.OperationResult{Message: "SUCCESS"}, nil
}

func (s *Server) ScheduleGenBatchTransferTask(ctx context.Context, e *empty.Empty) (*v1.OperationResult, error) {
	const op merrors.Op = "server.ScheduleGenBatchTransferTask"
	if err := service.NewTransferService(s.d, s.redis).BatchCreate(ctx); err != nil {
		return nil, merrors.E(op, merrors.Invalid, err)
	}
	return &v1.OperationResult{Message: "SUCCESS"}, nil
}
